/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package edu.capex.javacore.sockets;

import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.net.InetAddress;
import java.net.Socket;

/**
 *
 * @author IK
 */
public class ChatClient {
    public static void main(String[] args) {
        runClient();
    }
    public static void runClient() {
        Socket client;
        try {
            client = new Socket(InetAddress.getLocalHost(), 2000);

            DataInputStream sin = new DataInputStream(client.getInputStream());
            DataOutputStream sout = new DataOutputStream(client.getOutputStream());

            DataInputStream myin = new DataInputStream(System.in);

            while (true) {
                sout.writeUTF(myin.readLine());
                System.out.println(sin.readUTF());
            }
        } catch (Exception ex) {
            System.out.println(ex.getMessage());
        }


    }
}
